<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>管理员管理<!--{if $info['name']}-->--{$info['name']}<!--{/if}--></title>
        <link href="style/default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="./javascript/jquery.js">
        </script>
        <script type="text/javascript" src="./javascript/javascript.js">
        </script>
        <script>
            function addItem(obj, name){
                var html = '<tr class="item_' + name + '">';
                html += '<td><input type="text" name="key[' + name + '][]" class="short"></td>';
                html += '<td><input type="text" name="value[' + name + '][]" class="middle"></td>';
                html += '<td class="but" align="center"><a onclick="$(this).parent().parent().remove();"><img src="images/delete.gif"></a></td>';
                html += '</tr>';
                $('.item_' + name).last().after(html);
            }
            
            function delItem(obj){
                $(obj).parent().parent().remove();
            }
            
            function delGroup(name){
                $('.item_' + name).remove();
            }
            
            function addGroup(){
                var name = $('#new_group').val();
                if (name == '') {
                    return;
                }
                $('#new_group').val('');
                var html = '<tr class="item_' + name + '">';
                html += '<th colspan="2" align="left">';
                html += '<input type="text" name="group[' + name + ']" value="' + name + '" style="font-weight:bolder;">';
                html += '</th><th>';
                html += '<a onclick="addItem(this, \'' + name + '\');"><img src="images/new.gif"></a><a onclick="delGroup(\'' + name + '\');"><img src="images/delete.gif"></a>';
                html += '</th></tr>';
				$('.new_group').before(html);
            }
        </script>
    </head>
    <body>
        <!--{include nav.html}-->
        <div id="main">
            <form method="post">
                <table class="list">
                    <!--{foreach $config $name $con}-->
                    <tr class="item_{$name}">
                        <th colspan="2" align="left">
                            <input type="text" name="group[{$name}]" value="{$name}" style="font-weight:bolder;">
                        </th>
                        <th>
                            <a onclick="addItem(this, '{$name}');"><img src="images/new.gif"></a><a onclick="delGroup('{$name}');"><img src="images/delete.gif"></a>
                        </th>
                    </tr><!--{foreach $con $key $row}-->
                    <tr class="item_{$name}">
                        <td>
                            {$key}
                        </td>
                        <td>
                            <input type="text" name="conf[{$name}][{$key}]" value="{$row}" class="middle">
                        </td>
                        <td class="but" align="center">
                            <a onclick="delItem(this);"><img src="images/delete.gif"></a>
                        </td>
                    </tr><!--{/foreach}--><!--{/foreach}-->
                    <tr class="new_group">
                        <th colspan="2" align="left">
                            <input type="text" name="name" id="new_group">
                        </th>
                        <th>
                            <a onclick="addGroup()"><img src="images/new.gif"></a>
                        </th>
                    </tr>
                    <tr>
                        <th colspan="3">
                            <input type="submit" name="save" value="保存">
                        </th>
                    </tr>
                </table>
            </form>
        </div>
    </body>
</html>